package tss.serverGui;

import javax.swing.*;
import java.awt.*;

public class DrawArea extends JPanel {
    //main lines
    private Line trunk1;
    private Line trunk2;
    private Line trunk3;
    private Line trunk4;
    private Line trunk5;

    //lines needed for backward connections
    private Line backTrunk1;
    private Line backTrunk2;
    private Line backTrunk3;
    private Line backTrunk4;
    private Line backTrunk5;

    public DrawArea() {
	super();

	trunk1 = new Line();
	trunk2 = new Line();
	trunk3 = new Line();
	trunk4 = new Line();
	trunk5 = new Line();

	backTrunk1 = new Line();
	backTrunk2 = new Line();
	backTrunk3 = new Line();
	backTrunk4 = new Line();
	backTrunk5 = new Line();
    }

    public void paintComponent(Graphics g) {
	super.paintComponent(g);
	g.setColor(Color.blue);
	g.drawLine(trunk1.getX1(),trunk1.getY1(),trunk1.getX2(),trunk1.getY2());
	g.drawLine(backTrunk1.getX1(),backTrunk1.getY1(),backTrunk1.getX2(),backTrunk1.getY2());

	g.setColor(Color.red);
	g.drawLine(trunk2.getX1(),trunk2.getY1(),trunk2.getX2(),trunk2.getY2());
	g.drawLine(backTrunk2.getX1(),backTrunk2.getY1(),backTrunk2.getX2(),backTrunk2.getY2());

	g.setColor(Color.green);
	g.drawLine(trunk3.getX1(),trunk3.getY1(),trunk3.getX2(),trunk3.getY2());
	g.drawLine(backTrunk3.getX1(),backTrunk3.getY1(),backTrunk3.getX2(),backTrunk3.getY2());

	g.setColor(Color.yellow);
	g.drawLine(trunk4.getX1(),trunk4.getY1(),trunk4.getX2(),trunk4.getY2());
	g.drawLine(backTrunk4.getX1(),backTrunk4.getY1(),backTrunk4.getX2(),backTrunk4.getY2());

	g.setColor(Color.magenta);
	g.drawLine(trunk5.getX1(),trunk5.getY1(),trunk5.getX2(),trunk5.getY2());
	g.drawLine(backTrunk5.getX1(),backTrunk5.getY1(),backTrunk5.getX2(),backTrunk5.getY2());
    }

    public Dimension getPreferredSize() {
	return new Dimension(400,400);
    }

    public void setTrunk1(int x1, int y1, int x2, int y2) {
	trunk1.setLine(x1,y1,x2,y2);
    }
    public void setTrunk2(int x1, int y1, int x2, int y2) {
	trunk2.setLine(x1,y1,x2,y2);
    }
    public void setTrunk3(int x1, int y1, int x2, int y2) {
	trunk3.setLine(x1,y1,x2,y2);
    }
    public void setTrunk4(int x1, int y1, int x2, int y2) {
	trunk4.setLine(x1,y1,x2,y2);
    }
    public void setTrunk5(int x1, int y1, int x2, int y2) {
	trunk5.setLine(x1,y1,x2,y2);
    }

    public void setBackTrunk1(int x1, int y1, int x2, int y2) {
	backTrunk1.setLine(x1,y1,x2,y2);
    }
    public void setBackTrunk2(int x1, int y1, int x2, int y2) {
	backTrunk2.setLine(x1,y1,x2,y2);
    }
    public void setBackTrunk3(int x1, int y1, int x2, int y2) {
	backTrunk3.setLine(x1,y1,x2,y2);
    }
    public void setBackTrunk4(int x1, int y1, int x2, int y2) {
	backTrunk4.setLine(x1,y1,x2,y2);
    }
    public void setBackTrunk5(int x1, int y1, int x2, int y2) {
	backTrunk5.setLine(x1,y1,x2,y2);
    }
}
